import {post, get} from '@/util/request';

enum RequestPath {
  LOGIN_PATH = '/dreamland_admin/auth/login',
  CAPTCHA_PATH = '/dreamland_admin/auth/captcha',
  PEMISSION_PATH = '/dreamland_admin/auth/permission'

}

export interface LoginFormData {
  username: string;
  password: string;
  captcha: string;
}

export const requestLogin = (loginFormData: LoginFormData) => {
  return post<string>(RequestPath.LOGIN_PATH, loginFormData)
}

export const requestCaptcha = () => {
  return get<string>(RequestPath.CAPTCHA_PATH)
}

// 菜单数据结构
export interface Menum {
  id: string;
  icon?: string;
  matchedKey: string;
  name: string;
  path?: string;
  children?: Menum[];
}

export interface Button {
  id: string;
  matchedKey: string;
  name: string;
}

export interface Permission {
  menums?: Menum[];
  buttons?: Button[]
}

export const requestPermission = () => {
  const permission: Permission = {
    menums: [
      {
        id: '1',
        icon: 'User',
        matchedKey: '/404',
        name: '404页',
        path: '/404'
      }
    ]
  }
  return Promise.resolve<Permission>(permission)
  // return get<Permission>(RequestPath.PEMISSION_PATH)
}


